import service from "./config"
/**
 * 
 * @param {String} username 用户名
 * @param {String} password 密码
 * @returns voied
 */
//登录
export const login = (username, password) => {
    return service.post("/api/users/login", {
        username,
        password
    })
}

//获取验证码
export const getCaptcha = () => service.get("/api/users/getCaptcha")

//校验验证码
export const verifyCaptcha = captcha => service.get(`/api/users/verifyCaptcha?captcha=${captcha}`)

//获取登入日志

export const getlog = (page = 1, count = 20) => {
    return service.get(`/api/getloginlog?page=${page}$count=${count}`)
}

//获取权限菜单
export const getMenuList = () => {
    return service.get("/api/permission/getMenuList")
}

//获取列表
export const getStuList = (params = { page: 1, count: 10, classes: "" }) => service.get("/api/students/getstulist", {
    params: {
        page: params.page,
        count: params.count,
        class: params.classes
    }
})

//根据学员名字搜索学员 
export const searchStu = (page = 1, count = "", key = "") => service.get("/api/students/searchstu", {
    params: {
        page,
        count,
        key
    }
})


//获取任务数据
export const getTarskData = () => service.get("/data/tarsk.json")

//如果说服务器变更数据之后 本地服务器并没有更新
// 请求后加上时间戳

//获取rate数据
export const getRateData = () => service.get("/data/rate.json")

export const getExpectData = () => service.get("/data/expect.json")

//删除学员
export const delStu = (sId) => {
    return service.get(`/api/students/delstu?sId=${sId}`)
}

//增加学员信息
export const addStuReq = (params = {}) => {
    return service.post("/api/students/addstu",
        params
    )
}

//修改学员信息
export const editStuReq = (params = {}) => service.post("/api/students/updatestu", params)

//上传用户头像
export const uploadStuAvatar = (params = {}) => service.post("/api/users/uploadStuAvatar", params)

//获取天气接口
export const getWeather = (key = "",city="") => service.get("/api/weather/getWeather", {
    params: {
        key,
        city
    }
})

//修改密码
export const updatePassword = (params = {}) => service.post("/api/users/updatePassword", params)

//上传头像
export const uploadAvatar1 = (params = {}) => service.post("/api/users/uploadAvatar", params)